namespace SharpTalk.Core.Base
{
    using System;
    using System.Collections.Generic;
    using Data;
    using Diagnostic;
    using Interfaces;
    using System.Reflection;

    /// <summary>
    /// 
    /// </summary>
    public abstract class UserManagerBase : Traceable, IUserManager
    {
        private IUserDataProvider _dataprovider;

        protected UserManagerBase(IUserDataProvider dataProvider)
        {
            if (dataProvider == null) throw new ArgumentNullException("dataProvider");
            _dataprovider = dataProvider;
        }

        /// <summary>
        /// Obtains or defines the DataProvider
        /// </summary>
        public virtual IUserDataProvider DataProvider
        {
            get { return _dataprovider; }
            set { _dataprovider = value; }
        }
        /// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
        /// </summary>
        /// <filterpriority>2</filterpriority>
        public virtual void Dispose()
        {
            TraceMethodCall(MethodBase.GetCurrentMethod());
            if (_dataprovider == null) return;

            _dataprovider.Dispose();
            GC.SuppressFinalize(this);
        }
        /// <summary>
        /// 
        /// </summary>
        public virtual void Initialize()
        {
            TraceMethodCall(MethodBase.GetCurrentMethod());
            if(_dataprovider!=null)
                _dataprovider.Initialize();
        }
        /// <summary>
        /// 
        /// </summary>
        public virtual void ClearAll()
        {
            TraceMethodCall(MethodBase.GetCurrentMethod());
            if (_dataprovider != null)
                _dataprovider.ClearAll();
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public abstract bool Save(User obj);
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public abstract List<User> All();
        /// <summary>
        /// 
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public abstract User Update(User obj);
        /// <summary>
        /// 
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public abstract bool Delete(User obj);
        /// <summary>
        /// 
        /// </summary>
        /// <param name="guid"></param>
        /// <returns></returns>
        public abstract bool Delete(Guid guid);
        /// <summary>
        /// 
        /// </summary>
        /// <param name="guid"></param>
        /// <returns></returns>
        public abstract User Find(Guid guid);
        public abstract User Create(string firstName, string lastName, string nickName, byte[] image, string uri);
        public abstract List<User> Find(string firstName, string lastName, string nickName);
        public abstract void TrackUserChanges(User tracked, User tracker);
        public abstract void TrackUserChanges(User tracked, IEnumerable<User> trackers);
        public abstract void TrackUserChanges(IEnumerable<Guid> tracked, User tracker);
        public abstract IEnumerable<User> GetUserTrackingList(User user);
    }
}